package com.xunji.standard.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xunji.standard.entity.TXjNdFlMessageCall;
import com.xunji.standard.mapper.TXjNdFlMessageCallMapper;
import com.xunji.standard.service.TXjNdFlMessageCallService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author Administrator
 * @description 针对表【t_xj_nd_fl_message_call】的数据库操作Service实现
 * @createDate 2025-08-18 14:38:40
 */
@Service
public class TXjNdFlMessageCallServiceImpl extends ServiceImpl<TXjNdFlMessageCallMapper, TXjNdFlMessageCall> implements TXjNdFlMessageCallService {
    @Resource
    TXjNdFlPersonInformationServiceImpl personInformationService;

    @Override
    public List<TXjNdFlMessageCall> selectListByCaseIdAndInfoId(String caseId, Long infoId, String xm, String sfzh) {
        // 通过姓名身份证号，查询人员信息，获取手机号，查询短信记录
        List<String> lxfsList = personInformationService.getlxfsList(caseId, infoId, xm, sfzh);
        if (lxfsList == null || lxfsList.isEmpty()) {
            return null;
        }
        QueryWrapper<TXjNdFlMessageCall> qw = new QueryWrapper<>();
        qw.eq("case_id", caseId).in(!lxfsList.isEmpty(), "bjhm", lxfsList);
        return this.baseMapper.selectList(qw);
    }


    @Override
    public List<TXjNdFlMessageCall> selectListByCaseIdAndXmAndSfzh(String caseId, List<String> lxhmList) {
        if (lxhmList == null || lxhmList.isEmpty()) {
            return null;
        }
        QueryWrapper<TXjNdFlMessageCall> qw = new QueryWrapper<>();
        qw.eq("case_id", caseId).in("bjhm", lxhmList);
        return this.baseMapper.selectList(qw);
    }

    @Override
    public void deleteByCaseId(String caseId, String xm, String sfzh) {
        List<String> strings = personInformationService.getlxfsList(caseId, null, xm, sfzh);
        QueryWrapper<TXjNdFlMessageCall> qw = new QueryWrapper<>();
        qw.eq("case_id", caseId).in(!strings.isEmpty(), "bjhm", strings);
        this.baseMapper.delete(qw);
    }


}
